#! /bin/bash

function parse_ini()
{
    local ini_file=$1
    local section=$2
    local key=$3
    # echo ${ini_file}
    # echo ${section}
    # 提取指定 section 中的键值
    value=$(awk -F= -v section="[$section]" -v key="$key" '
        $0 == section { in_section=1; next }
        /^\[.*\]/     { in_section=0 }
        in_section && $1 == key { gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2; exit }
    ' "$ini_file")
    
    echo $value
}